package cn.gdcp.demo7;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btnAct2;
    private Button btnAct3;
    private Button btnAct4;
    private Button btnAct5;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnAct2 = findViewById(R.id.btn_act2);
        btnAct2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                /*intent.setAction("VIEW_STUDENT");
                startActivity(intent);*/

                //第一种
                intent.setClass(MainActivity.this,StuActivity.class);
                startActivity(intent);

                //第二种
                /*String packageName = "cn.gdcp.demo7";
                String className = "cn.gdcp.demo7.StuActivity";
                intent.setClassName(packageName,className);
                startActivity(intent);*/

                //第三种
                /*String className = "cn.gdcp.demo7.StuActivity";
                intent.setClassName(MainActivity.this,className);
                startActivity(intent);*/


                //跨包
                /*String className = "cn.gdcp.activity.StudentActivity";
                intent.setClassName(MainActivity.this,className);
                startActivity(intent);*/


            }
        });

        btnAct3 = findViewById(R.id.btn_act3);
        btnAct3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.baidu.com"));
                startActivity(intent);

            }
        });


        btnAct4 = findViewById(R.id.btn_act4);
        btnAct4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("geo:23.18318977782,133.3533287048"));
                startActivity(intent);



            }
        });


        btnAct5 = findViewById(R.id.btn_act5);
        btnAct5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction("I_WANT_EAT");
                intent.addCategory("NIU_ROU_FAN");
                startActivity(intent);


            }
        });

    }
}
